from ultralytics import YOLO
from PIL import Image
# Load a pretrained YOLO model (recommended for training)
# model = YOLO('yolov8n.pt')

# Perform object detection on an image using the model
# results = model(r'E:\ayanjiusheng\project\ultralytics-main\ultralytics\assets',show=True,save=True,save_conf=True,save_txt=True,name='output')

from ultralytics import YOLO
 
# Create a new YOLO model from scratch
model = YOLO(r'E:\ayanjiusheng\project\ultralytics-main\ultralytics\cfg\models\v8\yolov8.yaml')
 
# Load a pretrained YOLO model (recommended for training)
model = YOLO('yolov8n.pt')
 
# Train the model using the 'coco128.yaml' dataset for 3 epochs
results = model.train(data=r'E:\ayanjiusheng\project\ultralytics-main\ultralytics\cfg\datasets\mydataset.yaml',epochs=15,batch=1000)
 
# Evaluate the model's performance on the validation set
results = model.val()
#下面是预测和导出
# # Perform object detection on an image using the model
# results = model('https://ultralytics.com/images/bus.jpg')
#
# # Export the model to ONNX format
# success = model.export(format='onnx')